import { Descriptions, Drawer } from 'ant-design-vue'
import { authorizedIdentity_dict, progress_dict } from '../dict'

export default defineComponent({
  setup(_, { expose }) {
    const open = ref(false)
    const appInfo = ref<any>({})
    expose({
      open(row: any) {
        open.value = true
        appInfo.value = row
      },
    })
    return () => (
      <Drawer open={open.value} width="50%" title="详情" onClose={() => (open.value = false)}>
        <Descriptions bordered title="基本信息" column={2}>
          <Descriptions.Item label="应用ID">{appInfo.value.applicationId}</Descriptions.Item>
          <Descriptions.Item label="应用名称">{appInfo.value.applicationName}</Descriptions.Item>
          <Descriptions.Item label="锁定状态">{appInfo.value.nonLocked ? '锁定' : '未锁定'}</Descriptions.Item>
          <Descriptions.Item label="过期时间">{appInfo.value.deadline}</Descriptions.Item>
        </Descriptions>
        <br />
        <Descriptions bordered title="授权信息" column={3}>
          <Descriptions.Item label="授权人姓名">{appInfo.value.realName}</Descriptions.Item>
          <Descriptions.Item label="授权人手机号">{appInfo.value.phoneNumber}</Descriptions.Item>
          <Descriptions.Item label="授权人证件号">{appInfo.value.idCard}</Descriptions.Item>
          <Descriptions.Item label="授权企业">{appInfo.value.companyName}</Descriptions.Item>
          <Descriptions.Item label="授权类型">{authorizedIdentity_dict.find(it => it.value === appInfo.value.authorizedIdentity)?.label}</Descriptions.Item>
          <Descriptions.Item label="授权进度">{progress_dict.find(it => it.value === appInfo.value.progress)?.label}</Descriptions.Item>
          <Descriptions.Item label="授权时间">{appInfo.value.createTime}</Descriptions.Item>
        </Descriptions>
        <br />
        <Descriptions bordered title="企业信息" column={2}>
          <Descriptions.Item label="企业名称">{appInfo.value.companyName}</Descriptions.Item>
          <Descriptions.Item label="企业社会信用代码">{appInfo.value.creditCode}</Descriptions.Item>
          <Descriptions.Item label="法人姓名">{appInfo.value.legalName}</Descriptions.Item>
          <Descriptions.Item label="企业唯一标识">{appInfo.value.companyUniqueId}</Descriptions.Item>
        </Descriptions>
        <br />
        <Descriptions bordered title="其它信息" column={3}>
          <Descriptions.Item label="备注">{appInfo.value.remark}</Descriptions.Item>
        </Descriptions>
      </Drawer>
    )
  },
})
